package com.ruoyi.web.controller.article;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ArticleCategory;
import com.ruoyi.system.service.IArticleCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * articleCategoryController
 * 
 * @author star
 * @date 2024-09-05
 */
@RestController
@RequestMapping("/system/article_category")
public class ArticleCategoryController extends BaseController
{
    @Autowired
    private IArticleCategoryService articleCategoryService;

    /**
     * 查询articleCategory列表
     */
    @PreAuthorize("@ss.hasPermi('system:article_category:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArticleCategory articleCategory)
    {
        startPage();
        List<ArticleCategory> list = articleCategoryService.selectArticleCategoryList(articleCategory);
        return getDataTable(list);
    }

    /**
     * 导出articleCategory列表
     */
    @PreAuthorize("@ss.hasPermi('system:article_category:export')")
    @Log(title = "articleCategory", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArticleCategory articleCategory)
    {
        List<ArticleCategory> list = articleCategoryService.selectArticleCategoryList(articleCategory);
        ExcelUtil<ArticleCategory> util = new ExcelUtil<ArticleCategory>(ArticleCategory.class);
        util.exportExcel(response, list, "articleCategory数据");
    }

    /**
     * 获取articleCategory详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:article_category:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(articleCategoryService.selectArticleCategoryById(id));
    }

    /**
     * 新增articleCategory
     */
    @PreAuthorize("@ss.hasPermi('system:article_category:add')")
    @Log(title = "articleCategory", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArticleCategory articleCategory)
    {
        return toAjax(articleCategoryService.insertArticleCategory(articleCategory));
    }

    /**
     * 修改articleCategory
     */
    @PreAuthorize("@ss.hasPermi('system:article_category:edit')")
    @Log(title = "articleCategory", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArticleCategory articleCategory)
    {
        return toAjax(articleCategoryService.updateArticleCategory(articleCategory));
    }

    /**
     * 删除articleCategory
     */
    @PreAuthorize("@ss.hasPermi('system:article_category:remove')")
    @Log(title = "articleCategory", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(articleCategoryService.deleteArticleCategoryByIds(ids));
    }
}
